package com.gxs.tga.poc.domain;

import java.io.Serializable;
import java.util.UUID;

import javax.persistence.*;

import com.gxs.tga.poc.domain.dto.TgaSolutionTPDto;


/**
 * The persistent class for the TGA_SOLUTION_TP database table.
 * 
 */
@Entity
@Table(name="TGA_SOLUTION_TP")
@NamedQuery(name="TgaSolutionTP.findAll", query="SELECT t FROM TgaSolutionTP t")
public class TgaSolutionTP implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="TP_RECORD_ID", unique=true, nullable=false, length=36)
	private String tpRecordId;

	@Column(name="COMP_ID", nullable=false, length=36)
	private String compId;

	//bi-directional many-to-one association to TgaSolution
	@ManyToOne
	@JoinColumn(name="SOLUTION_ID", nullable=false)
	private TgaSolution tgaSolution;

	public TgaSolutionTP() {
	}

	public TgaSolutionTP(TgaSolutionTPDto tradingPartnerDTO, TgaSolution solution, boolean generateId)
	{
		this.tgaSolution = solution;
		
		this.compId = tradingPartnerDTO.getCompId();
		if(generateId)
		{
			this.tpRecordId = UUID.randomUUID().toString();
		}
		else
		{
			this.tpRecordId = tradingPartnerDTO.getTpRecordId();
		}
	}

	public String getTpRecordId() {
		return this.tpRecordId;
	}

	public void setTpRecordId(String tpRecordId) {
		this.tpRecordId = tpRecordId;
	}

	public String getCompId() {
		return this.compId;
	}

	public void setCompId(String compId) {
		this.compId = compId;
	}

	public TgaSolution getTgaSolution() {
		return this.tgaSolution;
	}

	public void setTgaSolution(TgaSolution tgaSolution) {
		this.tgaSolution = tgaSolution;
	}

}